//
//  TestFirstViewController.m
//  ProjectDemo
//
//  Created by IOS3 on 2018/10/24.
//  Copyright © 2018 IOS3. All rights reserved.
//

#import "TestFirstViewController.h"
#import "TestSearchViewController.h"
#import "TestSecondViewController.h"
#import <MMKV.h>

@interface TestFirstViewController ()

@end

@implementation TestFirstViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.tableVeiw registerClass:[UITableViewCell class] forCellReuseIdentifier:@"TestFirstViewControllerCell"];
    
    
    
    NSDictionary *params = @{@"key" : @"00d91e8e0cca2b76f515926a36db68f5",
                             @"phone" : @"13594347817",
                             @"passwd" : @"123456",
                             };
    self.loadingCount++;
    [APIRequest POST_default:@"/login" params:params complete:^(APIResponse * _Nonnull response) {
        self.loadingCount--;
    }];
    
    self.loadingCount++;
    [APIRequest GET_default:@"/login" params:params complete:^(APIResponse * _Nonnull response) {
        self.loadingCount--;
    }];
    
    self.loadingCount++;
    [APIRequest GET_default:API_test params:@{} complete:^(APIResponse * _Nonnull response) {
        self.loadingCount--;
    }];
    
    id aaa = @{
               @"str" : @"str",
               @"arr1" : @[@1, @2],
               @"arr2" : @{
                       @"str" : @"str",
                       @"arr1" : @[@1, @2],
                       }
               };
    MMKV *mkv = [MMKV defaultMMKV];
    [mkv setObject:aaa forKey:@"aaa"];
    id bb = [mkv getObjectOfClass:[NSDictionary class] forKey:@"aaa"];
    DLog(@"%@", bb);
    
//    self.view.backgroundColor = UIColor.whiteColor;
//    [self.tableVeiw removeFromSuperview];
//    UIImageView *imageView = [[UIImageView alloc] init];
//    imageView.frame = CGRectMake(100, 100, 100, 100);
//    UIImage *image1 = [UIImage imageWithColor:UIColor.blueColor];
//    imageView.image = image1;
//    
//    [self.view addSubview:imageView];
//    
//    UIButton *btn = [[UIButton alloc] init];
//    [btn setBackgroundImage:[UIImage imageWithColor:UIColor.redColor] forState:UIControlStateNormal];
//    btn.frame = CGRectMake(100, 200, 100, 100);
//    [self.view addSubview:btn];
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TestFirstViewControllerCell" forIndexPath:indexPath];
    cell.textLabel.text = @"TestFirstViewControllerCell";
//    cell.backgroundColor = [UIColor orangeColor];
    return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 30;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//    if (indexPath.row % 2 == 0) {
//        self.loadingCount++;
//    }
//    else {
//        self.loadingCount--;
//    }
//    return;
//    TestSecondViewController *vc = [[TestSecondViewController alloc] init];
//    vc.title = @"title";
//    [self.navigationController pushViewController:vc animated:true];
        TestSearchViewController *vc = [[TestSearchViewController alloc] init];
        vc.title = @"title";
        [self.navigationController pushViewController:vc animated:true];

}

@end
